package info.webest.reminder.receiver;

import info.webest.reminder.WidgetProvider;
import info.webest.reminder.service.CheckEventsService;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.provider.ContactsContract;
import android.widget.Toast;

/**
 * This broadcast receiver is awoken after boot and registers the service that
 * checks for new events from all the known contacts.
 */
public class BootReceiver extends BroadcastReceiver {
    public void onReceive(Context context, Intent intent) {
        
    	if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
        	
        	Toast.makeText(context, "Webest Reminder: BootReceiver", Toast.LENGTH_SHORT).show();
        	
    		context.getContentResolver().registerContentObserver(
    				ContactsContract.Contacts.CONTENT_URI, true, WidgetProvider.observer);
        	
        	CheckEventsService.schedule(context);        	        	
        }
    }
}